<#function getEditorValidator f>
	<#assign isrequired = false>
	<#assign v = '{type:"' + getEditorType(f) + '", options:{'>
	<#--
	<#if isRequried(f)>
		<#assign v = v + 'required:true, '>
	</#if>
	-->
	<#assign v = v + 'validType:['>
	<#if f.validators?? && (f.validators?length > 0)>
		<#list f.validators as o>
			<#assign o_v = getValidator(o)>
			<#if (o_v?length > 0)>
				<#assign v = v + "'" + o_v + "'">
				<#if o_has_next>
					<#assign v = v + ",">
				</#if>
			</#if>
		</#list>
	</#if>
	<#assign v = v + "], ">
	<#if isRequried(f)>
		<#assign v = v + "required:true,">
	</#if>
	<#assign v = v + getEditorOpt(f) + "}}">
	<#return v>
</#function>

<#function isRequried V>
	<#if V.validators?? && (V.validators?length > 0)>
		<#list V.validators as o>
			<#if o.type == "required">
				<#return true>
			</#if>
		</#list>
	</#if>
	<#return false>
</#function>

<#function getValidator V>
	<#assign r = "'a'">
	<#if V.type == "required">
		<#assign r = "">
	<#elseif V.type == "stringlength">
		<#assign l_min = "">
		<#assign l_max = "">
		<#list V.params as p>
			<#assign r_add = "">
			<#if p.name == "minLength">
				<#assign l_min = p.value>
			<#elseif p.name == "maxLength">
				<#assign l_max = p.value>
			</#if>
		</#list>
		<#if (l_min?length == 0)>
			<#assign l_min = "0">
		</#if>
		<#if (l_max?length == 0)>
			<#assign l_max = "1000">
		</#if>
		<#assign r = "length[" + l_min + "," + l_max + "]">
	<#elseif V.type == "email">
		<#assign r = "email">
	<#elseif V.type == "url">
		<#assign r = "url">
	</#if>
	<#return r>
</#function>

<#function getOptions f>
	<#assign opts = "">
	<#if f.options?? && (f.options?length > 0)>
		<#assign opts = opts + ' valueField:"v", textField:"k", data:['>
		<#list f.options as o>
			<#assign opts = opts + '{k:"' + o.label + '", v:"' + o.value + '"}'>
			<#if o_has_next><#assign opts = opts + ','></#if>
		</#list>
		<#assign opts = opts + ']'>
	</#if>
	<#return opts>
</#function>

<#function getEditorOpt f>
	<#assign jdbcType = f.type?lower_case>
	<#if f.options?? && (f.options?length > 0)>
		<#return "editable:false, " + getOptions(f)>
	</#if>
	<#assign jdbcType = jdbcType?lower_case>
	<#if jdbcType?contains("char") || jdbcType == "varchar" || jdbcType == "longvarchar">
		<#return "">
	<#elseif jdbcType == "numeric" || jdbcType == "decimal">
		<#return "">
	<#elseif jdbcType == "bit">
		<#return "">
	<#elseif jdbcType == "tinyint">
		<#return "">
	<#elseif jdbcType == "smallint">
		<#return "">
	<#elseif jdbcType == "int">
		<#return "">
	<#elseif jdbcType == "integer">
		<#return "">
	<#elseif jdbcType == "bigint">
		<#return "">
	<#elseif jdbcType == "real">
		<#return "">
	<#elseif jdbcType == "Float">
		<#return "">
	<#elseif jdbcType == "binary" || jdbcType == "varbinary" || jdbcType == "longvarbinary">
		<#return "">
	<#elseif jdbcType == "date">
		<#return "editable:false">
	<#elseif jdbcType == "datetime">
		<#return "editable:false">
	<#elseif jdbcType == "time">
		<#return "editable:false">
	<#elseif jdbcType == "timestamp">
		<#return "editable:false">
	<#else>
		<#return "">
	</#if>
</#function>

<#function getEditorType f>
	<#assign jdbcType = f.type?lower_case>
	<#if f.options?? && (f.options?length > 0)>
		<#return "combobox">
	</#if>
	<#assign jdbcType = jdbcType?lower_case>
	<#if jdbcType?contains("char") || jdbcType == "varchar" || jdbcType == "longvarchar">
		<#return "validatebox">
	<#elseif jdbcType == "numeric" || jdbcType == "decimal">
		<#return "numberbox">
	<#elseif jdbcType == "bit">
		<#return "numberbox">
	<#elseif jdbcType == "tinyint">
		<#return "numberbox">
	<#elseif jdbcType == "smallint">
		<#return "numberbox">
	<#elseif jdbcType == "int">
		<#return "numberbox">
	<#elseif jdbcType == "integer">
		<#return "numberbox">
	<#elseif jdbcType == "bigint">
		<#return "numberbox">
	<#elseif jdbcType == "real">
		<#return "numberbox">
	<#elseif jdbcType == "Float">
		<#return "numberbox">
	<#elseif jdbcType == "binary" || jdbcType == "varbinary" || jdbcType == "longvarbinary">
		<#return "validatebox">
	<#elseif jdbcType == "date">
		<#return "datebox">
	<#elseif jdbcType == "datetime">
		<#return "datetimebox">
	<#elseif jdbcType == "time">
		<#return "datetimebox">
	<#elseif jdbcType == "timestamp">
		<#return "datetimebox">
	<#else>
		<#return "validatebox">
	</#if>
</#function>